package com.github.edu.test.controller.filter;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;

/**
 * Create by IntelliJ IDEA
 * 用户：王建
 * 日期：2018-8-7
 */
public class MyCustomFilter implements Filter {


    private static final Logger log= LoggerFactory.getLogger(MyCustomFilter.class);

    /**
     * 拦截器初始化时，执行此方法
     * @param filterConfig
     * @throws ServletException
     */
    @Override
    public void init(FilterConfig filterConfig) throws ServletException {
        log.info("-------:init");
    }

    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        HttpServletRequest request=(HttpServletRequest) servletRequest;
        log.info("-------------doFilter:"+request.getRequestURI());
        filterChain.doFilter(servletRequest,servletResponse);
    }

    @Override
    public void destroy() {
        log.info("-------------拦截器销毁");
    }


}
